//utf-8
//点击新增按钮 事件跳转至 新增页面
function toAddData(type) {

	var obj = {
		"text" : '新建债权赎回',
		"url" : contextRootPath + '/creditRedem/prepareExecute/toAdd'
	};
	parent.showObj(obj);
}


//修改 事件
function toUpdateData(){
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待修改的数据！");
		return;
	}
	//如果选择多个 择提示
	if(v_ids.indexOf(",") > -1){
		alert("请选择一条数据！");
		return;
	}
	
	var contractCode = iframe.iframeObj["table"].getSelectedObjs("contractCode");
	var dealCode = iframe.iframeObj["table"].getSelectedObjs("dealCode");
	var obj={"text":'修改赎回交易',"url":contextRootPath+'/creditRedem/prepareExecute/toBackRedemptionUpdate?contractCode=' + contractCode + "&dealCode=" + dealCode + "&id=" + v_ids};
	parent.showObj(obj);
}


//删除 事件
function deleteData(){
	var v_ids = iframe.iframeObj["table"].getSelectedIds().join(",");
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待删除的数据！");
		return;
	}
	if(confirm("您确认要删除选择的数据吗？")){
        $.ajax({
            type:"POST",
            dataType : "json",
            url:contextRootPath+"/creditRedem/deleteDeal?ids="+v_ids,
            success:function(msg){
            	alert(msg.msg);
            	var v_status = msg.status;
            	//删除成功后
            	if(v_status.indexOf('ok') >-1){
            		iframe.iframeObj["table"].removeSelectedRow();
            	}
            	
            	
            }
        });
    }
}
//结算
function settleDeal(){
	var v_ids = iframe.iframeObj["table"].getSelectedObjs("dealCode").join(",");
	//如果没有选中 数据则
	if(v_ids == ""){
		alert("请选择待结算的数据！");
		return;
	}
	if(confirm("您确认要结算选择的数据吗？")){
        $.ajax({
            type:"POST",
            dataType : "json",
            url:contextRootPath+"/creditRedem/settleDeal?ids="+v_ids,
            success:function(msg){
            	alert(msg.msg);
            	var v_status = msg.status;
            }
        });
    }
}

//刷新结算状态
function refreshSettleStatus(){
	$.ajax({
		url: contextRootPath+"/creditDealController/realTimeUpdateSettleResult",
		type: 'post',
		dataType: 'json',
		success: function(msg) {
				jyDialog({"type":"info"}).alert(msg.msg);
				var v_status = msg.status;
		    	if(v_status.indexOf('ok') >-1){
		    		queryData();
		    	}
				
		}
	});
}